home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Demo / lutz / psh.py next >
Encoding:
Text File  |  1994-10-08  |  9.9 KB  |  61 lines  |  [TEXT/R*ch]

  1.  in __main__'
  2.         print 'Type \'help <cmd>\' for more information on a specific command\n'
  3.  
  4.  
  5.  
  6.  
  7. ############################################
  8. # run shell; 'shell.go()' restarts is again
  9. # note: 'shell' is not available in __main__
  10. # yet, until this file is completely read,
  11. # so you can't 'db' shell stuff until you
  12. # 'quit' and call 'shell.xxx()' directly;
  13. #
  14. # load (src's) '.PshInit' if present in cwd;
  15. # should also ckeck home dir too;  useful
  16. # for canned 'equ' aliase commands, 'os' 
  17. # and 'prompt' commands, etc;
  18. ############################################
  19.  
  20.  
  21.  
  22.  
  23. def go():
  24.     print '-Python command shell-'
  25.     try:
  26.         src(['.PshInit'])
  27.         print 'loaded .PshInit'
  28.     except:
  29.         print '.PshInit file not found'
  30.     interact()
  31.     print 'command shell exit.'
  32.  
  33.  
  34. go()
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. ##################################################
  42. # notes;
  43. # eval() succeeds for python cmds too
  44. # exec() runs with local=function in 'shell'
  45. # 'import *' adds os/string funcs to 'shell'
  46. #
  47. # def shell_command(name):
  48. #     import shell
  49. #     return (name in shell.__dict__.keys())
  50. ##################################################    
  51. # import sys
  52. # exec(join(args), \
  53. #         sys.modules['__main__'].__dict__, \
  54. #         sys.modules['__main__'].__dict__)
  55. #
  56. # 'x' = sys.modules['__main__'].x
  57. # 'x' = sys.modules['__main__'].__dict__['x']
  58. ##################################################
  59.  
  60.  
  61.